import { FetchReservationLogData, FetchMccMeetingLogData, FetchMccLogDetailListData } from '@/api/sysLog/interface'
import { ReservationLogData, MccMeetingLogData, MccLogDetailListData, integrityCheckMenu } from './interface'
import dayjs from '@/plugins/dayjs'
import { t } from 'i18next'

export const transFetchReservationLogData = (data: FetchReservationLogData[]): ReservationLogData[] => {
	return data.map((i) => ({
		id: i.id,
		operational: i.operational,
		operator: i.operator,
		operating_time: i.operating_time ? dayjs(i.operating_time).format('YYYY-MM-DD HH:mm:ss') : '',
		operator_ip: i.operator_ip,
		operation_result: i.operation_result ? t('成功') : t('失败'),
		result_fail: i.result_fail,
		integrity_check: integrityCheckMenu[i.integrity_check],
	}))
}

export const transFetchMccMeetingLogData = (data: FetchMccMeetingLogData[]): MccMeetingLogData[] => {
	return data.map((i) => ({
		meeting_moid: i.meeting_moid,
		name: i.category === 1 ? '[VCS]' + i.name : i.name,
		creator: i.creator,
		start_time: i.start_time ? dayjs(i.start_time).format('YYYY-MM-DD HH:mm:ss') : '',
		end_time: i.end_time ? dayjs(i.end_time).format('YYYY-MM-DD HH:mm:ss') : '',
		integrity_check: integrityCheckMenu[i.integrity_check],
	}))
}

export const transFetchMccLogDetailListData = (data: FetchMccLogDetailListData[]): MccLogDetailListData[] => {
	return data.map((i) => ({
		id: i.id,
		operational: i.operational,
		operator: i.operator ?? '',
		operating_time: i.operatingTime ? dayjs(i.operatingTime).format('YYYY-MM-DD HH:mm:ss') : '',
		operator_ip: i.operatorIp,
		operation_result: i.operationResult ? t('成功') : t('失败'),
		result_fail: i.resultFail ?? '',
	}))
}
